home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / InfoTipManager.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  1.3 KB  |  50 lines

  1. package symantec.itools.awt;
  2.  
  3.  
  4. import java.awt.Color;
  5. import java.awt.Font;
  6. import java.awt.FontMetrics;
  7. import java.awt.Panel;
  8.  
  9. /**
  10.  * This helper class draws InfoTips
  11.  * @version 
  12.  * @author Symantec
  13.  */
  14. public class InfoTipManager
  15. {
  16.     private static Panel infoTipPanel;
  17.  
  18.     /**
  19.      * Creates a new Panel for the InfoTip as needed and then returns it.
  20.      * @return a Panel for the InfoTip
  21.      */
  22.     public static Panel getInfoTipPanel()
  23.     {
  24.         if(infoTipPanel == null)
  25.         {
  26.             infoTipPanel = new Panel();
  27.             infoTipPanel.hide();
  28.             infoTipPanel.setLayout(null);
  29.         }
  30.  
  31.         return infoTipPanel;
  32.     }
  33.  
  34.     /**
  35.      * Draws the InfoTip.
  36.      * @param x location of the InfoTip, x coordinate
  37.      * @param y location of the InfoTip, y coordinate
  38.      * @param s text to display in the InfoTip
  39.      * @param fm font used for InfoTip text
  40.      * @param bc background color used for the InfoTip
  41.      * @param fc foreground color used for the InfoTip
  42.      */
  43.     public static void draw(int x, int y, String s, FontMetrics fm, Color bc, Color fc)
  44.     {
  45.         infoTipPanel.reshape(x, y, fm.stringWidth(s), fm.getHeight());
  46.         infoTipPanel.setBackground(bc);
  47.         infoTipPanel.setForeground(fc);
  48.         infoTipPanel.show();
  49.     }
  50. }